package robusta.aidstools.findbugs.buginstance;

import org.jdom.Element;

public class Method {
	private String classname;
	private String name;
	private String start;
	private String end;
	
	public final String CLASSNAME = "classname";
	public final String NAME = "name";
	public final String START = "start";
	public final String END = "end"; 
	
	public Method(Element e) {
		classname = e.getAttributeValue(CLASSNAME);
		name = e.getAttributeValue(NAME);
		Element sourceLine = e.getChild("SourceLine");
		start = sourceLine.getAttributeValue(START);
		end = sourceLine.getAttributeValue(END);
	}
	
	public String getClassname() {
		return classname;
	}
	
	public String getJavaName() {
		int dotIndex = classname.lastIndexOf(".");
		StringBuilder sb = new StringBuilder();
		sb.append(classname.substring(dotIndex + 1)).append(".java");
		return sb.toString();
	}
	
	public String getName() {
		return name;
	}
	
	public String getStart() {
		return start;
	}
	
	public String getEnd() {
		return end;
	}
}
